#include<bits/stdc++.h>
#include<conio.h>
#define int long long
#define endl putchar('\n')
#define psp putchar(' ')
using namespace std;
const int N=1e6+5;
const int M=1e3+5;
int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
void print(int x){
	if(x<0)putchar('-'),x=-x;
	if(x<10){putchar(x+'0');return;}
	print(x/10);
	putchar(x%10+'0');
}
int n=25,m,k;
int T;
char c[M][M];
// 0
//3+1
// 2
int way[5];
int x[5],y[5];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
char wayname[4]={'U','R','D','L'};
bool move(int id){
	int xx=x[id]+dx[way[id]];
	int yy=y[id]+dy[way[id]];
	if(xx<1||yy<1||xx>n||yy>n||c[xx][yy]!='.')return 0;
	c[x[id]][y[id]]='.';
	x[id]=xx,y[id]=yy;
	c[x[id]][y[id]]='0'+id;
	return 1;
}
void turnr(int id){
	way[id]++;
	way[id]%=4;
}
void turnl(int id){
	way[id]--;
	way[id]+=4;
	way[id]%=4;
}
int life[5]={0,1,1,1,1};
void K(int id){
	for(int i=1;i<=2;i++){
		int xx=x[id]+dx[way[id]]*i;
		int yy=y[id]+dy[way[id]]*i;
		if(xx<1||yy<1||xx>n||yy>n)continue;
		bool flag=0;
		if(c[xx][yy]=='.'||c[xx][yy]=='#')flag=(c[xx][yy]=='#'),c[xx][yy]='.';
		else life[c[xx][yy]-'0']=0,c[xx][yy]='.';
		if(flag)break;
	}
}
signed main(){
	//ios::sync_with_stdio(0);
	srand(time(0));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			c[i][j]='.';
		}
	}
	T=n*10;
	while(T--){
		int xx=(rand()-1)%n+1;
		int yy=(rand()-1)%n+1;
		while(xx<0||yy<0||xx>n||yy>n||c[xx][yy]!='.'){
			xx=(rand()-1)%n+1;
			yy=(rand()-1)%n+1;
		}
		c[xx][yy]='#';
	}
	for(int i=1;i<=4;i++){
		int xx=(rand()-1)%n+1;
		int yy=(rand()-1)%n+1;
		while(xx<0||yy<0||xx>n||yy>n||c[xx][yy]!='.'){
			xx=(rand()-1)%n+1;
			yy=(rand()-1)%n+1;
		}
		c[xx][yy]=i+'0';
		x[i]=xx,y[i]=yy;
		way[i]=rand()%4;
	}
	while(life[1]+life[2]+life[3]+life[4]>=2){
		for(int id=1;id<=4;id++){
			if(!life[id])continue;
			char op;
			bool flag=1;
			while(flag){
				system("cls");
				for(int i=1;i<=4;i++){
					cout<<i<<" now way:"<<wayname[way[i]]<<"\t";
				}
				cout<<"\n\n";
				for(int i=1;i<=n;i++){
					for(int j=1;j<=n;j++){
						cout<<c[i][j];
					}
					cout<<'\n';
				}
				cout<<"\nnow is "<<id<<" time.\n";
				cout<<"W advance,R turn right,L turn left,K hit.\n";
				cin>>op;
				flag=0;
				if(op=='W'){
					flag=!move(id);
				}
				else if(op=='R'){
					turnr(id);
				}
				else if(op=='L'){
					turnl(id);
				}
				else if(op=='K'){
					K(id);
				}
				else flag=1;
			}
		}
	}
	for(int i=1;i<=4;i++){
		if(life[i]){
			cout<<i<<" win.";
			break;
		}
	}
}
